#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;

inline int read() {
	int x = 0;
	bool f = false;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-')
			f = true;
		ch = getchar();
	}
	while (isdigit(ch))
		x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

const int N = 500001;
int a[N];
long long ans = 0;

void gb_sort(int l, int r) {
	if (l == r) return;
	int mid = (l + r) >> 1;
	gb_sort(l, mid);
	gb_sort(mid + 1, r);
	static int b[N];
	int pl = l, pr = mid + 1, cur = l;
	while (pl <= mid && pr <= r)
		if (a[pl] <= a[pr])
			b[cur++] = a[pl++];
		else {
			b[cur++] = a[pr++];
			ans += mid - pl + 1;
		}
	while (pl <= mid) b[cur++] = a[pl++];
	while (pr <= r) b[cur++] = a[pr++];
	for (int i = l; i <= r; ++i) a[i] = b[i];
}
int n;

int main() {
	n = read();
	for (int i = 0; i < n; i++) a[i] = read();
	gb_sort(0, n - 1);
	printf("%d", ans);
	return 0;
}
